export const priceFormat = (num : number | string) : number | string => {
	let numText : string | number
	if (num) {
		if (String(num).indexOf('.') >= 0) {

			if (String(num).indexOf('.') + 2 == String(num).length) {
				numText = num + '0'
			} else {
				numText = num
			}
		} else {
			numText = num + '.00'
		}
	}
	return numText
}
export const formatDateY_M_D = (date : string | number | Date,
	bre : any) : string => {
	if (!date) {
		return ""
	} else {
		bre = bre ? bre : '-';
		let time : Date = new Date(date)
		let year : number = time.getFullYear()
		let month : number = time.getMonth() + 1
		let day : number = time.getDate()
		return year +
			bre + (month > 9 ? month : '0' + month) +
			bre + (day > 9 ? day : '0' + day)
	}
}
// 月日形式
export const formatDateM_D2 = (date : Date | string | number) : string => {
	if (!date) {
		return ""
	} else {
		let time : Date = new Date(date)
		let month : number = time.getMonth() + 1
		let day : number = time.getDate()
		return (month > 9 ? month : '0' + month) +
			'月' + (day > 9 ? day : '0' + day) + '日'
	}
}
export const formatDateY_M_D_H_M_S = (date : string | number | Date,
	bre : any) : string => {
	if (!date) {
		return ""
	} else {
		bre = bre ? bre : '/';
		let time : Date = new Date(date)
		let year : number = time.getFullYear()
		let month : number = time.getMonth() + 1
		let day : number = time.getDate()
		let hour : number = time.getHours()
		let min : number = time.getMinutes()
		let sec : number = time.getMinutes()
		return year +
			bre + (month > 9 ? month : '0' + month) +
			bre + (day > 9 ? day : '0' + day) + " " + (hour > 9 ? hour : '0' + hour) +
			":" + (min > 9 ? min : '0' + min) + ":" + (sec > 9 ? sec : '0' + sec)
	}
}
export const formatDateM_D_H_M = (date : string | number | Date,
	bre : any) : string => {
	if (!date) {
		return ""
	} else {
		bre = bre ? bre : '/';
		let time : Date = new Date(date)
		let month : number = time.getMonth() + 1
		let day : number = time.getDate()
		let hour : number = time.getHours()
		let min : number = time.getMinutes()
		return (month > 9 ? month : '0' + month) +
			bre + (day > 9 ? day : '0' + day) + " " + (hour > 9 ? hour : '0' + hour) +
			":" + (min > 9 ? min : '0' + min)
	}
}
export const formatDateH_M = (date : string | number | Date,
	bre : any) : string => {
	if (!date) {
		return ""
	} else {
		bre = bre ? bre : ':';
		let time : Date = new Date(date)
		let hour : number = time.getHours()
		let min : number = time.getMinutes()
		return (hour > 9 ? hour : '0' + hour) +
			bre + (min > 9 ? min : '0' + min)
	}
}

export const getSystemInfo = () : Promise<any> => {
	return new Promise((resolve, reject) => {
		uni.getSystemInfo({
			success: (info) => {
				resolve(info); // 成功时返回 info
			},
			fail: (err) => {
				reject(err); // 失败时返回错误
			},
		});
	});
};